home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Audio, Video & Photo / Audacity 1.3.5 / audacity-win-unicode-1.3.5.exe / {app} / Plug-Ins / vocalremover.ny < prev    next >
Lisp/Scheme  |  2008-02-10  |  7KB  |  106 lines

  1. ;nyquist plug-in
  2. ;version 3
  3. ;type process
  4. ;name "Vocal Remover (for center-panned vocals)..."
  5. ;action "Removing vocals or other center-panned audio..."
  6. ;info "by David R. Sky www.shellworld.net/~davidsky/ \nReleased under terms of the GNU General Public License version 2 \nRemoves center-panned audio in a stereo track by inversion and panning to center.\n\n'Simple' removal removes all the center-panned audio. If too much audio is removed,\ntry removing only selected frequencies - enter these in the box 'Frequency band\nlower and upper limit'. Then choose 'Remove band' to remove only frequencies in\nthat band, or 'Retain band' to remove only frequencies outside that band. After\nremoval, the audio will sound mono because both channels are panned to center.\n\nFor further help, select 'View Help' in the first dropdown menu and click OK. After\nreading Help, please reopen Vocal Remover to use it.\n"
  7.  
  8.  
  9. ;control action "Remove vocals or view Help" choice "Remove vocals,View Help" 0
  10. ;control bc "Removal choice" choice "Simple (entire spectrum),Remove frequency band,Retain frequency band" 0
  11. ;control range "Frequency band lower and upper limit [Hz]\n [Enter two values between 0 and 20000]" string " " "500 2000"
  12.  
  13. ; Center pan Remover by David R. Sky November 12, 2004
  14. ; updated October/November 2007. Further modified by 
  15. ; Gale Andrews January 2008 to make full spectrum removal 
  16. ; the default, restore a single Help screen and restore error checking.
  17. ; Ideally wants rewriting so that no error checking occurs when
  18. ; default full spectrum removal selected.
  19. ; Thanks to David Hostetler for notes in his own vocal remover plug-in,
  20. ; which makes this plug-in more effective. See -
  21. ; http://www.freelists.org/archives/audacity4blind/06-2006/msg00049.html
  22.  
  23. (cond ; either explain this effect or perform it
  24. ((= action 1) ; display Help screen
  25. (format nil
  26. "Vocal Remover requires a stereo track and works best on audio in a lossless format\nlike WAV or AIFF rather than a compressed, lossy format like MP3. If your song is on\na CD, use a program like CD-ex to rip it to WAV or AIFF before using Vocal Remover. 
  27.  
  28. Vocals (or other audio) can only be removed with this plug-in when panned to center,\nin other words sounding equally loud in both left and right channels. Vocals are often\nrecorded this way. When one channel is inverted and then both panned to center,\nany audio which is identical in both channels is cancelled out, so becomes inaudible.\nThis means that if audio you don't want to remove also happens to be center-panned,\nit will be cancelled out along with the vocals. Drums are an example of audio that is\noften center-panned and can thus disappear when vocals are removed. However, if\nthe vocals and other center-panned parts of the audio differ from each other in pitch\n(and thus in frequency), removing only selected frequencies from the audio can solve\nsuch problems. 
  29.  
  30. Vocal Remover therefore has three choices of removal method. 'Simple' inverts the\nentire frequency spectrum of one channel. If all the audio except the vocals is panned\nhard away from center, this will work the best. If some of the other audio is common\nto both channels, this choice may remove too much music, in which case try the\nremaining options. 'Remove frequency band' removes frequencies in a band whose\nupper and lower limit you specify in the 'Frequency band...' box. Try this choice,\nentering the approxmate frequency range of the vocals, if they are apparently at a\nvery different pitch than the other audio (for example, a high female voice). 'Retain\nfrequency band' removes only those frequencies lying outside the limit you specify,\nretaining the others. This choice can help if there is audio of a particular frequency\nrange (such as low drums or bass) that is lost when using the other methods. Simply\nenter the approximate frequency range of the audio you wish to retain."))
  31.  
  32.  
  33. (t ; perform effect
  34. (defun string-to-list (str)
  35. (read (make-string-input-stream (format nil "(~a)" str))))
  36.  
  37.  
  38. (setf range (string-to-list range))
  39.  
  40. ; initialize empty error-msg
  41. (setf error-msg "")
  42.  
  43. ; Error-checking...
  44. ;
  45. ; check that selected audio is stereo
  46. (setf error-msg (if (arrayp s)
  47. error-msg
  48. (strcat error-msg (format nil
  49. "Error:\n\nVocal Remover requires an unsplit, stereo track.\n\nIf you have a stereo track split into left and right\nchannels, use 'Make Stereo Track' on the Track\nDropdown Menu, then run Vocal Remover again. 
  50. "))))
  51.  
  52.  
  53. ; Check there are two input frequency values given. If not and remove or retain band is selected,  
  54. ; ask to enter their required values. If not and 'Simple' removal selected, ask to enter any two values. 
  55. (setf error-msg (if 
  56. (and (> bc 0)
  57. (< (length range) 2))
  58. (strcat error-msg (format nil
  59. "Error:\n\nPlease enter both a lower and upper value for the\nfrequency band you want to remove or retain.\n\nBoth values must be between 0 and 20000.
  60. " (nth bc '("" ""))))
  61.  
  62. ; are range values numbers?  
  63. (if
  64. (or (not (numberp (first range))) (not (numberp (second range))))
  65. (strcat error-msg (format nil
  66. "To perform 'Simple' removal you can enter any\ntwo numbers (separated by a space) in the\n'Frequency band lower and upper limit' box.\nThe numbers entered don't affect the result.\n\nTo remove or retain a frequency band, enter\nlower and upper values for the band between\n0 and 20000.
  67. " (first range) (second range)))
  68.  
  69. ; if 'Simple' removal not selected, throw error if both frequency values are not between 0 and 20000
  70. (if (or (= bc 0)
  71. (and 
  72. (>= (first range) 0) (<= (first range) 20000)
  73. (>= (second range) 0) (<= (second range) 20000)))
  74. error-msg
  75. (strcat error-msg (format nil
  76. "Error:\n\n~aAt least one frequency value in your band is invalid. \nYou entered: ~a   ~a\n\nBoth the lower and upper values must be between\n0 and 20000.
  77. "(nth bc '("" "" ""))
  78. (first range) (second range)))))))
  79.  
  80.  
  81. (cond
  82. ((> (length error-msg) 0)
  83. (format nil "~a" error-msg))
  84.  
  85. (t ; no error msg
  86. (setf lower (min (first range) (second range)))
  87. (setf upper (max (first range) (second range)))
  88.  
  89.  
  90. (cond
  91. ((= bc 1) ; invert [delete] band of frequencies inside range
  92. (sum (aref s 0) (mult -1 (aref s 1))
  93. (highpass8 (aref s 1) upper)
  94. (lowpass8 (aref s 1) lower)))
  95.  
  96. ((= bc 2) ; invert [delete] frequencies outside band range
  97. (sum (aref s 0) (mult -1 (aref s 1))
  98. (highpass8 (lowpass8 (aref s 1) upper) lower)))
  99.  
  100. (t ; invert one channel
  101. (sum (aref s 0) (mult -1 (aref s 1)))))
  102. ) ; end t apply effect
  103. ) ; end cond between display error msg or apply effect
  104. ) ; end t perform effect
  105. ) ; end cond explain effect or perform it
  106.